//
//  DefineConstant.h
//  JiangSuAuction
//
//  Created by Abner on 2018/8/6.
//  Copyright © 2018年 Abner. All rights reserved.
//

//***屏幕相关***//
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define TABBAR_HEIGHT (STATUSBAR_HEIGHT > 20 ? 83.0f : 49.0f)
#define NAVIBAR_HEIGHT (IS_OS_7_Later ? (IS_INCH_X || IS_INCH_MAX || IS_INCH_XR) ? 88.0f : 64.0f : 44.0f)
#define YRGBColor(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
#define YRGBAColor(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define kImageDefaltBookCover [UIImage imageNamed:@"default_book_cover"]
#define kImageDefaltAuthorAvatar [UIImage imageNamed:@"bd_add_count"]
#define STATUSBAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height
#define defaultHt (SCREEN_HEIGHT == 480 ? 568 : SCREEN_HEIGHT)
#define autoSizeScaleX (SCREEN_WIDTH/375)
#define autoSizeScaleY (defaultHt/667)
#define AutoCGRectMake(x,y,width,height) (CGRectMake(x*autoSizeScaleX,y*autoSizeScaleY,width*autoSizeScaleX,height*autoSizeScaleY))
#define AutoCGSizeMake(width,height) (CGSizeMake(width*autoSizeScaleX,height*autoSizeScaleY))
#define kUIScaleBasePlus [UIScreen mainScreen].bounds.size.width/375.0
#define kContentSize     CGSizeMake(SCREEN_WIDTH - 40, is5_8inches?SCREEN_HEIGHT - 120:SCREEN_HEIGHT - 80)
#define is5_8inches ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)//字体
#define DCDefaultTextFontName @"PingFang SC"
#define DCDefaultTextFontSize 20*kUIScaleBasePlus
#define DCDefaultTextFont [UIFont fontWithName:DCDefaultTextFontName size:DCDefaultTextFontSize]
//***屏幕尺寸相关***//
#define IS_INCH_3_5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \
CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_4   ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \
CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_4_7  ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \
CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_5_5   ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \
CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_XR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)

#define IS_INCH_MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)

//***系统版本相关***//
#define IS_OS_7_Later ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0)

//***颜色相关***//
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define LCHexColor(hexValue) [UIColor colorWithRed:(hexValue>>16)/255.0 green:(hexValue>>8&0xff)/255.0 blue :(hexValue&0xff)/255.0 alpha:1]
#define LCHexAColor(hexValue,a) [UIColor colorWithRed:(hexValue>>16)/255.0 green:(hexValue>>8&0xff)/255.0 blue:(hexValue&0xff)/255.0 alpha:a]
//#define JSAMainColor LCHexColor(0x0DA8FF)
#define JSAMainColor LCHexColor(0xF54337)
#define JSALineColor LCHexColor(0xEBE5E1)
#define JSAMainBgColor LCHexColor(0xffffff)
#define contextFont 20

//***文字相关***//
#define Font(f) ([UIFont systemFontOfSize:f*autoSizeScaleX])
#define kMainTitleFont [UIFont boldSystemFontOfSize:16.5]
#define kDescTitleFont [UIFont systemFontOfSize:14]

//***其他相关***//
#define WeakSelf(type) __weak __typeof(&*self)weakSelf = self;
#define StrongSelf(type) __strong typeof(type) type = weak##type;

#define JSAAPPDELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)
#define JSAKEYWINDOW [[UIApplication sharedApplication] keyWindow]
#define JSAUSERDEFAULTS [NSUserDefaults standardUserDefaults]
#define JSANOTIFICATIONCENTER [NSNotificationCenter defaultCenter]
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)

#define Image(path) ([[NSString stringWithFormat:@"%@%@",kImageBaseUrl,path] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]])

#define AdapteAdjust(objectX) KScreenWidth  == IPhone6Width ? objectX : KScreenWidth  == IPhone6PWidth ?  objectX  : objectX *  0.853

#define IPhone6Width 375.00
#define IPhone6Height 667.00

#define IPhone6PWidth 414.00
#define IPhone6PHeight 736.00

#define kPost @"POST"
#define kGet  @"GET"
#define PageSize 10

#define DISMISS_VP(time) \
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ \
[SVProgressHUD dismiss]; \
});

#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#ifdef DEBUG
#define NSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define NSLog(...)

#endif

